package com.zh.seckill.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 返回结果
 *
 * @Author: zhanghuan
 * @date: 2022/3/28 11:16
 * @description: create it
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {

    private long code;
    private String message;
    private Object object;

    public static R success() {
        return new R(RespEnum.SUCCESS.getCode(), RespEnum.SUCCESS.getMessage(), null);
    }

    public static R success(Object object) {
        return new R(RespEnum.SUCCESS.getCode(), RespEnum.SUCCESS.getMessage(), object);
    }

    public static R error(RespEnum respEnum) {
        return new R(respEnum.getCode(), respEnum.getMessage(), null);
    }

    public static R error(RespEnum respEnum, Object object) {
        return new R(respEnum.getCode(), respEnum.getMessage(), object);
    }
}
